<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>

    <script src="../static/js/vue.js"></script>
    <script src="https://unpkg.com/http-vue-loader"></script>
    <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
    <script src="https://unpkg.com/element-ui@2.15.8/lib/index.js"></script>
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
</head>
<body>
<div id="app">
    <app v-on:submit_form="submit_form" :flag="flag"></app>
</div>


<script>
    // Vue.use("httpvueloader")
    Vue.use('axios');

    var app = new Vue({
        el: '#app',
        data: {
            flag: true
        },
        components:{
            'app': httpVueLoader('../static/components/register.vue')
        },
        methods:{
            submit_form(data) {
                const user={name:data.name,password:data.pass}
                axios({
                    method:'post',
                    url:'http://localhost:8080/register',
                    data:user,
                    headers: {
                        'Content-Type': 'application/json;charset=UTF-8'
                    }
                }).then((res)=>{

                    if(res.data==="注册成功"){
                        console.log(res.data);
                        this.flag=false;

                    }
                })
            }
        }

    })
</script>

</body>
</html>